package com.android.likeweixin;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.widget.emoji.EmojiconEditText;
import org.widget.emoji.OnEditTextPasteListener;
import org.widget.pulltorefresh.PullToRefreshBase;
import org.widget.pulltorefresh.PullToRefreshBase.Mode;
import org.widget.pulltorefresh.PullToRefreshListView;

import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.text.Editable;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.ImageSpan;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.SimpleAdapter;
import android.widget.Toast;

import com.android.likeweixin.asynctask.LoadFriendDynamicTask;
import com.android.likeweixin.dialog.PicSelectDialog;
import com.android.likeweixin.model.FriendDynamic;
import com.android.likeweixin.model.FriendDynamic.Comment;
import com.android.likeweixin.util.ResolutionUtily;
import com.android.likeweixin.util.StorageUtils;
import com.android.likeweixin.util.StringUtily;
import com.android.likeweixin.util.Util;

public class FriendCircleActivity extends BaseActivity implements
		OnClickListener {
	private Button captureBtn;
	private View backBtn;

	private PullToRefreshListView mPullRefreshListView;
	private ListView mListView;
	private FriendCircleListAdapter mAdapter;

	private LoadFriendDynamicTask mfdTask;
	// 评论区域
	private ViewPager viewpager;

	private GridView expressionGriView1;

	private GridView expressionGriView2;

	private GridView expressionGriView3;

	private GridView expressionGriView4;

	private LinearLayout layout_point;

	private int current = 0;

	private EmojiconEditText etSendText = null;
	private Button btnSend = null;
	private ViewGroup chatting_xml;
	private Button biaoqinBtn;
	// 表情页界面集合
	private ArrayList<View> pageViews;
	private ArrayList<ImageView> pointViews;
	private PicSelectDialog captureDialog;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.friend_circle);
		captureDialog = new PicSelectDialog(this, R.style.dialog);
		captureBtn = (Button) findViewById(R.id.capture);
		backBtn = findViewById(R.id.back);
		captureBtn.setOnClickListener(this);
		backBtn.setOnClickListener(this);
		initView();
		addBqListener();
		Init_Data();
		editTextListener();
		mfdTask = new LoadFriendDynamicTask(this, 0);
		mfdTask.execute(null, null);
	}

	private void addBqListener() {
		biaoqinBtn = (Button) findViewById(R.id.btn_biaoqin);
		etSendText = (EmojiconEditText) findViewById(R.id.et_sendmessage);
		btnSend = (Button) findViewById(R.id.btn_send);
		btnSend.setOnClickListener(this);
		chatting_xml = (ViewGroup) getLayoutInflater().inflate(
				R.layout.chatting_gridview1, null);
		expressionGriView1 = (GridView) chatting_xml
				.findViewById(R.id.blog_sendmsg_gvemotion1);
		expressionGriView2 = (GridView) chatting_xml
				.findViewById(R.id.blog_sendmsg_gvemotion2);
		expressionGriView3 = (GridView) chatting_xml
				.findViewById(R.id.blog_sendmsg_gvemotion3);
		expressionGriView4 = (GridView) chatting_xml
				.findViewById(R.id.blog_sendmsg_gvemotion4);
		viewpager = (ViewPager) findViewById(R.id.viewpager);
		layout_point = (LinearLayout) findViewById(R.id.iv_image);
		final EditText et_sendmessage = (EditText) findViewById(R.id.et_sendmessage);
		// 生成gridview和viewpager
		ArrayList<HashMap<String, Object>> lstImageItem1 = new ArrayList<HashMap<String, Object>>();
		ArrayList<HashMap<String, Object>> lstImageItem2 = new ArrayList<HashMap<String, Object>>();
		ArrayList<HashMap<String, Object>> lstImageItem3 = new ArrayList<HashMap<String, Object>>();
		ArrayList<HashMap<String, Object>> lstImageItem4 = new ArrayList<HashMap<String, Object>>();
		try {
			for (int i = 1; i < 85; i++) {
				HashMap<String, Object> map = new HashMap<String, Object>();
				String j = "";
				if (i < 10) {
					j = "new_expression_frame_00";
				} else {
					j = "new_expression_frame_0";
				}
				// 从R.drawable类中获得相应资源ID（静态变量）的Field对象
				Field field = R.drawable.class.getDeclaredField(j + i);
				// 获得资源ID的值，也就是静态变量的值
				int resourceId = field.getInt(R.drawable.class);
				// 添加图像资源的ID
				map.put("ItemImage", resourceId);
				if (i <= 21) {
					lstImageItem1.add(map);
				} else if (i > 21 & i <= 42) {
					lstImageItem2.add(map);
				} else if (i > 42 & i <= 63) {
					lstImageItem3.add(map);
				} else if (i > 63) {
					lstImageItem4.add(map);
				}

			}
			SimpleAdapter saImageItems1 = new SimpleAdapter(
					FriendCircleActivity.this, lstImageItem1,
					R.layout.gridview_emotion_item,
					new String[] { "ItemImage" },
					new int[] { R.id.blog_sendmsg_emotion });
			SimpleAdapter saImageItems2 = new SimpleAdapter(
					FriendCircleActivity.this, lstImageItem2,
					R.layout.gridview_emotion_item,
					new String[] { "ItemImage" },
					new int[] { R.id.blog_sendmsg_emotion });
			SimpleAdapter saImageItems3 = new SimpleAdapter(
					FriendCircleActivity.this, lstImageItem3,
					R.layout.gridview_emotion_item,
					new String[] { "ItemImage" },
					new int[] { R.id.blog_sendmsg_emotion });
			SimpleAdapter saImageItems4 = new SimpleAdapter(
					FriendCircleActivity.this, lstImageItem4,
					R.layout.gridview_emotion_item,
					new String[] { "ItemImage" },
					new int[] { R.id.blog_sendmsg_emotion });
			expressionGriView1.setAdapter(saImageItems1);
			expressionGriView2.setAdapter(saImageItems2);
			expressionGriView3.setAdapter(saImageItems3);
			expressionGriView4.setAdapter(saImageItems4);
			pageViews = new ArrayList<View>();
			pageViews.add(expressionGriView1);
			pageViews.add(expressionGriView2);
			pageViews.add(expressionGriView3);
			pageViews.add(expressionGriView4);
			// 移除原gridview和父节点关系，塞入viewpager容器
			chatting_xml.removeAllViews();
			viewpager.setAdapter(new ViewPagerAdapter(pageViews));
		} catch (SecurityException e) {
			e.printStackTrace();
		} catch (NoSuchFieldException e) {
			e.printStackTrace();
		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
		biaoqinBtn.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// 隐藏输入法
				InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
				imm.hideSoftInputFromWindow(et_sendmessage.getWindowToken(), 0);
				// 底部区域上移
				if (viewpager.getVisibility() == View.GONE) {
					viewpager.setVisibility(View.VISIBLE);
					layout_point.setVisibility(View.VISIBLE);
				} else if (viewpager.getVisibility() == View.VISIBLE) {
					viewpager.setVisibility(View.GONE);
					layout_point.setVisibility(View.GONE);
				}
				expressionGriView1
						.setOnItemClickListener(new ItemClickListener());
				expressionGriView2
						.setOnItemClickListener(new ItemClickListener());
				expressionGriView3
						.setOnItemClickListener(new ItemClickListener());
				expressionGriView4
						.setOnItemClickListener(new ItemClickListener());
			}

			class ItemClickListener implements OnItemClickListener {
				/**
				 * 点击项时触发事件
				 * 
				 * @param parent
				 *            发生点击动作的AdapterView
				 * @param view
				 *            在AdapterView中被点击的视图(它是由adapter提供的一个视图)。
				 * @param position
				 *            视图在adapter中的位置。
				 * @param rowid
				 *            被点击元素的行id。
				 */
				@Override
				public void onItemClick(AdapterView<?> parent, View view,
						int position, long rowid) {
					HashMap<String, Object> item = (HashMap<String, Object>) parent
							.getItemAtPosition(position);
					// 第4页倒数几个透明图片不响应click事件
					int k = parent.getId();
					int l = expressionGriView4.getId();
					if (current == 3 & position > 15 & position < 20) {
						return;
					}
					// 最后一个删除按钮
					else if (position == 20) {
						int selection = etSendText.getSelectionStart();
						String text = etSendText.getText().toString();
						if (selection > 0) {
							String text2 = text.substring(selection - 1);
							if ("]".equals(text2)) {
								int start = text.lastIndexOf("[");
								int end = selection;
								etSendText.getText().delete(start, end);
								return;
							}
							etSendText.getText().delete(selection - 1,
									selection);
						}

					} else {
						// 获取当前Item的资源id
						int imageId = (Integer) item.get("ItemImage");
						String itemText = getResources().getResourceName(
								imageId);
						itemText = itemText.substring(itemText.lastIndexOf("/") + 1);
						// 根据资源ID获得资源图像的Bitmap对象
						Drawable drawable;
						drawable = getResources().getDrawable(imageId);
						// int width = drawable.getIntrinsicHeight();
						int size = (int) (24.0f * ResolutionUtily
								.getDensicy(FriendCircleActivity.this));
						drawable.setBounds(0, 0, size, size);
						ImageSpan imageSpan = new ImageSpan(drawable,
								ImageSpan.ALIGN_BOTTOM);
						SpannableString spannableString = new SpannableString(
								"[" + itemText + "]");
						// 用ImageSpan对象替换表情
						spannableString.setSpan(imageSpan, 0,
								itemText.length() + 2,
								Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
						// 将获得的图像追加到EditText控件的最后
						etSendText.append(spannableString);
					}
				}

			}

		});

	}

	/**
	 * edittext点击监听
	 */
	private void editTextListener() {
		etSendText.setOnKeyListener(new View.OnKeyListener() {

			@Override
			public boolean onKey(final View v, int keyCode, KeyEvent event) {
				System.out.println("onKey:" + keyCode);
				if (keyCode == KeyEvent.KEYCODE_BACK) {
					// if (viewpager.getVisibility() == View.VISIBLE) {
					viewpager.setVisibility(View.GONE);
					layout_point.setVisibility(View.GONE);
					View commentBottom = findViewById(R.id.commentBottom);
					commentBottom.setVisibility(View.GONE);
					etSendText.setText("");
					etSendText.clearFocus();
					Util.hideInputMethod(FriendCircleActivity.this, etSendText);
					mListView.postDelayed(new Runnable() {
						@Override
						public void run() {
							mListView.setSelection((Integer) v
									.getTag(R.id.fd_postion));
						}
					}, 900);
					// }
				}
				return false;
			}
		});
		etSendText.setOnPasteListener(new OnEditTextPasteListener() {
			@Override
			public void onPaste(String text) {
				if (text.startsWith("_img")) {
					etSendText.setText("[图片]");
				} else {
					int start = etSendText.getSelectionStart();
					int end = etSendText.getSelectionEnd();
					Editable ea = etSendText.getText();
					if (start != end) {
						ea.delete(start, end);
					}
					ea.insert(start, StringUtily.getExpressionString(
							getBaseContext(), text));
				}
			}
		});
		etSendText.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// 底部区域上移
				if (viewpager.getVisibility() == View.VISIBLE) {
					viewpager.setVisibility(View.GONE);
					layout_point.setVisibility(View.GONE);
				}

			}

		});
	}

	/**
	 * 填充数据
	 */
	private void Init_Data() {
		// 初始化游标点
		pointViews = new ArrayList<ImageView>();
		ImageView imageView;
		for (int i = 0; i < 4; i++) {
			imageView = new ImageView(getBaseContext());
			if (i == 0) {
				imageView.setBackgroundResource(R.drawable.pic_noa);
			} else {
				imageView.setBackgroundResource(R.drawable.pic_nob);
			}

			LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
					new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT,
							LayoutParams.WRAP_CONTENT));
			layoutParams.leftMargin = 10;
			layoutParams.rightMargin = 10;
			layoutParams.topMargin = 2;
			layoutParams.bottomMargin = 10;
			layoutParams.width = 10;
			layoutParams.height = 10;
			layout_point.addView(imageView, layoutParams);
			pointViews.add(imageView);
		}
		viewpager.setOnPageChangeListener(new OnPageChangeListener() {

			@Override
			public void onPageSelected(int arg0) {
				current = arg0;
				// 描绘分页点
				for (int i = 0; i < 4; i++) {
					if (arg0 == i) {
						pointViews.get(i).setBackgroundResource(
								R.drawable.pic_noa);
					} else {
						pointViews.get(i).setBackgroundResource(
								R.drawable.pic_nob);
					}
				}
			}

			@Override
			public void onPageScrolled(int arg0, float arg1, int arg2) {

			}

			@Override
			public void onPageScrollStateChanged(int arg0) {

			}
		});
	}

	private void initView() {
		mPullRefreshListView = (PullToRefreshListView) findViewById(R.id.listview);
		// Set a listener to be invoked when the list should be refreshed.
		mPullRefreshListView
				.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {

					@Override
					public void onPullDownToRefresh(
							PullToRefreshBase<ListView> refreshView) {
						System.out.println("onPullDownToRefresh");
						mfdTask = new LoadFriendDynamicTask(
								FriendCircleActivity.this, 0);
						// mfdTask.execute(ServerUtil.getFriendDynamicUrl(),
						// String.valueOf(0));
					}

					@Override
					public void onPullUpToRefresh(
							PullToRefreshBase<ListView> refreshView) {
						System.out.println("onPullUpToRefresh");
						mfdTask = new LoadFriendDynamicTask(
								FriendCircleActivity.this, 0);
						// mfdTask.execute(ServerUtil.getFriendDynamicUrl(),
						// String.valueOf(0));
					}
				});
		mPullRefreshListView.setMode(Mode.BOTH);
		mPullRefreshListView
				.setScrollingWhileRefreshingEnabled(!mPullRefreshListView
						.isScrollingWhileRefreshingEnabled());
		mListView = mPullRefreshListView.getRefreshableView();
		mAdapter = new FriendCircleListAdapter(this, null);
		mListView.setAdapter(mAdapter);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.back:
			finish();
			break;
		case R.id.capture:
			//captureDialog.show();
			break;
		case R.id.btn_send:
			View commentBottom = findViewById(R.id.commentBottom);
			String msgBody = etSendText.getText().toString();
			if (msgBody == null || msgBody.trim().equals("")) {
				Toast.makeText(this, "发送内容不能为空!", Toast.LENGTH_SHORT).show();
				return;
			}
			// 评论后调用刷新
			final int position = (Integer) etSendText.getTag(R.id.fd_postion);
			Comment c = (Comment) etSendText.getTag(R.id.fd_comment);
			c.commentContent = msgBody;
			c.userId = FriendDynamic.getLoginUserId();
			c.realName = FriendDynamic.getLoginUserName();
			// 调用评论接口
			UploadCommentTask ut = new UploadCommentTask(position, c);
			ut.execute(c);
			// 隐藏评论区域
			commentBottom.setVisibility(View.GONE);
			etSendText.setText("");
			etSendText.clearFocus();
			Util.hideInputMethod(this, etSendText);
			// 底部区域上移
			if (viewpager.getVisibility() == View.VISIBLE) {
				viewpager.setVisibility(View.GONE);
				layout_point.setVisibility(View.GONE);
			}
			mListView.postDelayed(new Runnable() {
				@Override
				public void run() {
					mListView.setSelection(position);
				}
			}, 900);

			break;
		default:
			break;
		}

	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		if (resultCode != RESULT_OK) {
			return;
		}
		Uri uri = null;
		switch (requestCode) {
		case PicSelectDialog.CAMERA_SUCCESS:
			/*
			 * if (data != null) { Bundle bundle = data.getExtras(); if (bundle
			 * != null) { Bitmap bitmap = (Bitmap) bundle.get("data"); } } File
			 * file = new File(picPath); if (file.exists()) { uri =
			 * Uri.fromFile(file); }
			 */
			if (data != null) {
				uri = data.getData();
				// 如果uri为null,那么拍照返回的可能是位图
				if (uri == null) {
					Bundle bundle = data.getExtras();
					Bitmap bitmap = (Bitmap) bundle.get("data");
					try {
						File file = StorageUtils
								.getCacheDirectory(LikeWeixinApp.getInstance());
						file = new File(file.getPath(),
								System.currentTimeMillis() + ".jpg");
						FileOutputStream out = new FileOutputStream(file);
						bitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
						uri = Uri.fromFile(file);
					} catch (FileNotFoundException e) {
						e.printStackTrace();
					}
				}
			} else {
				File file = new File(captureDialog.getCameraPicPath());
				if (file.exists()) {
					uri = Uri.fromFile(file);
				}
			}
			break;
		case PicSelectDialog.PHOTO_SUCCESS:
			uri = data.getData();
		default:
			break;
		}

		// Intent intent = new Intent(this, FriendPublishNewsActivity.class);
		// intent.setData(uri);
		// System.out.println("uri:" + uri);
		// startActivity(intent);
	}

	/**
	 * 获得被选择的图片路径
	 * 
	 * @param context
	 *            上下文
	 * @param data
	 *            图片数据
	 * @return 图片路径
	 */
	public String getSelectedImagePath(Context context, Intent data) {
		String selectedImgPath = null;
		Uri uri = data.getData();
		if (uri != null) {
			String uriStr = uri.toString();
			// 类型1：content://media/external/images/media/3059
			// 类型2：content://com.android.providers.media.documents/document/image:3059
			Cursor cursor = null;
			String[] columns = { MediaStore.Images.Media.DATA };
			// API4.4++
			if (uriStr.contains("com.android.providers.media.documents")) {
				String id = parseImageId(uriStr);
				String where = MediaStore.Images.Media._ID + "=?";
				cursor = context.getContentResolver().query(
						MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns,
						where, new String[] { id }, null);
				// API4.3--
			} else {
				cursor = context.getContentResolver().query(uri, columns, null,
						null, null);
			}
			if (cursor.moveToFirst()) {
				selectedImgPath = cursor.getString(cursor
						.getColumnIndex(columns[0]));
			}
			cursor.close();
		}

		return selectedImgPath;
	}

	/**
	 * 获得相册中选择图片的ID
	 * 
	 * @param uri
	 *            URI
	 * @return 图片ID
	 */
	public String parseImageId(String uri) {
		// content://com.android.providers.media.documents/document/image:3059
		// content://com.android.providers.media.documents/document/image%3A3059
		String imageId = null;
		if (!TextUtils.isEmpty(uri)) {
			String endStr = uri.substring(uri.lastIndexOf("/") + 1);
			// 把转义符%3A的还原成冒号
			if (endStr.contains("%3A")) {
				endStr.replace("%3A", ":");
			}
			imageId = endStr.split(":")[1];
		}
		return imageId;
	}

	@Override
	public void onPostExecute(int type, Map<String, Object> result) {
		if (type == 0) {
			List<FriendDynamic> datas = (List<FriendDynamic>) result
					.get("data");
			mAdapter.refresh(datas);
			mPullRefreshListView.onRefreshComplete();
		}
	}

	class ItemClickListener implements OnItemClickListener {
		/**
		 * 点击项时触发事件
		 * 
		 * @param parent
		 *            发生点击动作的AdapterView
		 * @param view
		 *            在AdapterView中被点击的视图(它是由adapter提供的一个视图)。
		 * @param position
		 *            视图在adapter中的位置。
		 * @param rowid
		 *            被点击元素的行id。
		 */
		@Override
		public void onItemClick(AdapterView<?> parent, View view, int position,
				long rowid) {
			HashMap<String, Object> item = (HashMap<String, Object>) parent
					.getItemAtPosition(position);
			// 第4页倒数几个透明图片不响应click事件
			int k = parent.getId();
			int l = expressionGriView4.getId();
			if (current == 3 & position > 15 & position < 20) {
				return;
			}
			// 最后一个删除按钮
			else if (position == 20) {
				int selection = etSendText.getSelectionStart();
				String text = etSendText.getText().toString();
				if (selection > 0) {
					String text2 = text.substring(selection - 1);
					if ("]".equals(text2)) {
						int start = text.lastIndexOf("[");
						int end = selection;
						etSendText.getText().delete(start, end);
						return;
					}
					etSendText.getText().delete(selection - 1, selection);
				}

			} else {
				// 获取当前Item的资源id
				int imageId = (Integer) item.get("ItemImage");
				String itemText = getResources().getResourceName(imageId);
				itemText = itemText.substring(itemText.lastIndexOf("/") + 1);
				// 根据资源ID获得资源图像的Bitmap对象
				Drawable drawable;
				drawable = getResources().getDrawable(imageId);
				// int width = drawable.getIntrinsicHeight();
				int size = (int) (24.0f * ResolutionUtily
						.getDensicy(FriendCircleActivity.this));
				drawable.setBounds(0, 0, size, size);
				ImageSpan imageSpan = new ImageSpan(drawable,
						ImageSpan.ALIGN_BOTTOM);
				SpannableString spannableString = new SpannableString("["
						+ itemText + "]");
				// 用ImageSpan对象替换表情
				spannableString.setSpan(imageSpan, 0, itemText.length() + 2,
						Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
				// 将获得的图像追加到EditText控件的最后
				etSendText.append(spannableString);
			}
		}
	}

	private class UploadCommentTask extends AsyncTask<Comment, Void, Comment> {
		private int position;
		private Comment ct;

		public UploadCommentTask(int position, Comment c) {
			this.position = position;
			ct = c;
		}

		@Override
		protected Comment doInBackground(Comment... cmts) {
			Comment c = cmts[0];
			// String url = ServerUtil.getCommentUrl();
			// HttpClientUtil http = new HttpClientUtil();
			// Map<String, String> httpParams = new HashMap<String, String>();
			// httpParams.put("newsId", c.newsId);
			// httpParams.put("commentContent", c.commentContent);
			// httpParams.put("userId", c.userId);
			// httpParams.put("realName", c.realName);
			// httpParams.put("replyUserId", c.replyUserId);
			// httpParams.put("replyRealName", c.replyRealName);
			// String jsonStr = http.doGetRequest(url, httpParams);
			// System.out.println("##jsonStr:" + jsonStr);
			// try {
			// JSONObject obj = new JSONObject(jsonStr);
			// c.commentId = obj.getString("commentId");
			// } catch (JSONException e) {
			// e.printStackTrace();
			// }
			return c;
		}

		@Override
		protected void onPostExecute(Comment c) {
			super.onPostExecute(c);
			if (!TextUtils.isEmpty(c.commentId)) {
				mAdapter.refreshComment(position, c);
				Toast.makeText(FriendCircleActivity.this, "评论成功！",
						Toast.LENGTH_SHORT).show();
			} else {
				Toast.makeText(FriendCircleActivity.this, "评论失败！",
						Toast.LENGTH_SHORT).show();
			}
		}
	}
}
